extends /templates/core/modal-base-flat

mixin ageRange(name)
  select.age-range-select.form-control(name=name value=view.classroom.get(name))
    option(value="") -
    option(value="<6" data-i18n="courses.student_age_range_younger")
    for i in _.range(6,18)
      option(value=i)= i
    option(value="18" data-i18n="courses.student_age_range_older")

block modal-header-content
  if view.classroom.isNew()
    h3.modal-title(data-i18n="courses.create_new_class")
  else
    h3.modal-title(data-i18n="courses.edit_settings1")

block modal-body-content
  form
    .row
      .col-lg-6.col-md-12
        if view.shouldShowGoogleClassroomButton()
          a#link-google-classroom-btn.btn.btn-primary.btn-lg(data-i18n="courses.link_google_classroom")

        if view.shouldShowLMSButton()
          a#link-lms-classroom-btn.btn.btn-primary.btn-lg(data-i18n="courses.link_lms_classroom")

        if view.showLMSDropDown
          .form-group.lms-class-name
            label(data-i18n="courses.select_your_classroom")
            if view.lmsClassrooms.length > 0
              select.select-lms-class.form-control(name="lmsClassroomId" type='text')
                option(value="" data-i18n="courses.select_your_classroom")
                for classroom in view.lmsClassrooms
                  option(value = classroom.id)= classroom.name
            else
              select.select-lms-class.form-control(name="lmsClassroomId" type='text' disabled=true)
                option(value="" data-i18n="courses.no_classrooms_found")
              a.small.create-manually
                u(data-i18n="courses.create_classroom_manually")


        .form-group.google-class-name.secret
          label(data-i18n="courses.select_your_classroom")
          if view.googleClassrooms.length > 0
            select.select-google-class.form-control(name="googleClassroomId" type='text')
              option(value="" data-i18n="courses.select_your_classroom")
              for classroom in view.googleClassrooms
                option(value = classroom.id)= classroom.name
          else
            select.select-google-class.form-control(name="googleClassroomId" type='text' disabled=true)
              option(value="" data-i18n="courses.no_classrooms_found")
            a.small.create-manually
              u(data-i18n="courses.create_classroom_manually")

        .form-group.class-name
          label(data-i18n="courses.class_name")
          input#name-input.form-control(name="name" type='text' value=view.classroom.get('name'))

        .form-group
          label(data-i18n="choose_hero.programming_language")
          - var aceConfig = view.classroom.get('aceConfig') || {};
          - var languageWarning = !!_.size(view.classroom.get('members'));
          if languageWarning
            .help-block.small.text-navy(data-i18n="teachers.programming_language_edit_desc_new")
          select#programming-language-select.form-control(name="language" value=aceConfig.language)
            - var aceConfig = view.classroom.get('aceConfig') || {};
            option(value="" data-i18n="courses.language_select")
            option(value="python" data-i18n="courses.python") Python
            option(value="javascript" data-i18n="courses.javascript") JavaScript
            if view.enableCpp
              option(value="cpp") C++
            if view.enableJava
              option(value="java" data-i18n="courses.java") Java (Beta)

        .form-group
          label
            span(data-i18n="courses.classroom_items")
            span= ': '
            input#classroom-items(name="classroomItems" checked=view.classroom.get('classroomItems', true) type='checkbox')
          .help-block.small.text-navy(data-i18n="teachers.classroom_items_description")

        .form-group
          label
            span(data-i18n="courses.classroom_live_completion")
            - var aceConfig = _.assign({liveCompletion: true},  view.classroom.get('aceConfig'))
            - var liveCompletion = aceConfig.liveCompletion
            input#live-completion(name="liveCompletion" checked=liveCompletion type='checkbox')
          .help-block.small.text-navy(data-i18n="teachers.classroom_live_completion")

        .code-formats-part
          if view.enableBlocks
            // TODO: check is junior course included
            - var allCodeFormats = ['text-code', 'blocks-and-code', 'blocks-text', 'blocks-icons']
            label
              span(data-i18n="teachers.code_formats")
            .form-group
              - var aceConfig = view.classroom.get('aceConfig') || {}
              - var codeFormats = aceConfig.codeFormats
              if codeFormats === undefined
                - codeFormats = ['text-code']
                // Later, we can turn everything on by default
                // - codeFormats = isJunior ? allCodeFormats : _.omit(allCodeFormats, 'blocks-icons')
              each format in allCodeFormats
                - var i18nPrefix = 'choose_hero.' + format.replace(/-/g, '_')
                label.checkbox-inline(data-i18n="[title]" + i18nPrefix + "_blurb")
                  input.codeformats-checkbox(name="codeFormats" value=format checked=codeFormats.includes(format) type='checkbox')
                  span(data-i18n="choose_hero." + format.replace(/-/g, '_'))
              .help-block.small.text-navy(data-i18n="teachers.code_formats_description")
              label
                span(data-i18n="teachers.default_code_format")
              - var aceConfig = view.classroom.get('aceConfig') || {}
              - var codeFormatDefault = aceConfig.codeFormatDefault
              if codeFormatDefault === undefined
                - codeFormatDefault = 'text-code'
              select.form-control#default-codeformat-select(name="codeFormatDefault" value=codeFormatDefault)
                each format in view.enabledCodeFormats
                  - var i18nPrefix = 'choose_hero.' + format.replace(/-/g, '_')
                  option(value=format)= $.i18n.t(i18nPrefix) + ' - ' + $.i18n.t(i18nPrefix + '_blurb')
              .help-block.small.text-navy(data-i18n="teachers.default_code_format_description")
  
        .form-group
          label
            span(data-i18n="teachers.classroom_level_chat")
            span= ': '
            - var aceConfig = _.assign({levelChat: 'fixed_prompt_only'},  view.classroom.get('aceConfig'))
            - var levelChat = aceConfig.levelChat
            - var levelChatAllowed = levelChat === 'fixed_prompt_only'
            input#level-chat(name="levelChat" checked=levelChatAllowed value='fixed_prompt_only' type='checkbox')
          .help-block.small.text-navy(data-i18n="teachers.classroom_level_chat_blurb")

      .col-lg-6.col-md-12
        .form-group
          label
            span(data-i18n="courses.classroom_announcement")
            i.spl.text-muted(data-i18n="signup.optional")
            .pick-image-button.btn.btn-middle.btn-forest(data-i18n="common.pick_image")
          textarea#classroom-announcement.form-control(name="description" rows=2)= view.classroom.get('description')

        .form-group.hide
          // We don't show this any more, as we didn't do anything with the data anyway
          label
            span(data-i18n="courses.avg_student_exp_label")
            i.spl.text-muted(data-i18n="signup.optional")
          .help-block.small.text-navy(data-i18n="courses.avg_student_exp_desc")
          select.form-control(name="averageStudentExp", value=view.classroom.get('averageStudentExp'))
            option(value="" data-i18n="courses.avg_student_exp_select")
            option(value="none" data-i18n="courses.avg_student_exp_none")
            option(value="beginner" data-i18n="courses.avg_student_exp_beginner")
            option(value="intermediate" data-i18n="courses.avg_student_exp_intermediate")
            option(value="advanced" data-i18n="courses.avg_student_exp_advanced")
            option(value="varied" data-i18n="courses.avg_student_exp_varied")

        .form-group
          label(for="type")
            span(data-i18n="courses.class_type_label")
            if (!me.isILK())
              i.spl.text-muted(data-i18n="signup.optional")
          select.form-control(name="type", value=view.classroom.get('type'))
            option(value="" data-i18n="courses.avg_student_exp_select")
            if !me.isCodeNinja()
              option(value="in-school" data-i18n="courses.class_type_in_school")
            option(value="after-school" data-i18n="courses.class_type_after_school")
            if !me.isCodeNinja()
              option(value="online" data-i18n="courses.class_type_online")
              option(value="camp" data-i18n="courses.class_type_camp")
              option(value="homeschool" data-i18n="courses.class_type_homeschool")
              option(value="other" data-i18n="courses.class_type_other")

        .form-group
          label
            span(data-i18n="courses.student_age_range_label")
            i.spl.text-muted(data-i18n="signup.optional")
          div
            +ageRange("ageRangeMin")
            span.spl.spr(data-i18n="courses.student_age_range_to")
            +ageRange("ageRangeMax")

        .form-group
          label
            span(data-i18n="courses.estimated_class_dates_label")
            i.spl.text-muted(data-i18n="signup.optional")
          div
            input.class-dates.form-control(name="classDateStart" type="date" value=view.classroom.get('classDateStart') max="9999-12-31")
            span.spl.spr(data-i18n="courses.student_age_range_to")
            input.class-dates.form-control(name="classDateEnd" type="date" value=view.classroom.get('classDateEnd') max="9999-12-31")

        .form-group
          label
            span(data-i18n="courses.estimated_class_frequency_label")
            i.spl.text-muted(data-i18n="signup.optional")
          div.row
            .col-sm-5
              select.classes-per-week-select.form-control(name="classesPerWeek", value=view.classroom.get('classesPerWeek'))
                for i in _.range(1,6)
                  option(value = i)= i
              .help-block.small.text-navy.m-l-1.classes-per-week-help(data-i18n="courses.classes_per_week")
            .col-sm-5
              select.minutes-per-class-select.form-control(name="minutesPerClass", value=view.classroom.get('minutesPerClass'))
                option(value="<30")= '<30'
                option(value="30")= '30'
                option(value="50")= '50'
                option(value="75")= '75'
                option(value=">75")= '>75'
              .help-block.small.text-navy.m-l-1.minutes-per-class-help(data-i18n="courses.minutes_per_class")

block modal-footer-content
  .text-center
    if view.classroom.isNew()
      button#save-settings-btn.btn.btn-primary.btn-lg(data-i18n="courses.create_class")
    else
      button#save-settings-btn.btn.btn-primary.btn-lg(data-i18n="common.save_changes")

    if me.isAdmin()
      hr
      //- DNT
      h3 Admin Only
      button#update-courses-btn.btn.btn-forest.btn-lg Update Courses
